//******************************************************************
//******************************************************************
//**********          ANts Peer To Peer Sources        *************
//
// ANts P2P realizes a third generation P2P net. It protects your
// privacy while you are connected and makes you not trackable, hiding
// your identity (ip) and crypting everything you are sending/receiving
// from others.

// Copyright (C) 2004  Roberto Rossi

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

package ants.p2p.gui;

import javax.swing.*;

import java.awt.event.*;

import ants.p2p.*;
import ants.p2p.irc.*;

import org.jibble.pircbot.*;
import org.apache.log4j.*;
import java.beans.*;

public class ChatPopupMenu extends JPopupMenu {
  ChatAntPanel callerChat;
  User user;

  JMenu jMenu1 = new JMenu();
  JMenuItem jMenuItem14 = new JMenuItem();
  JMenuItem jMenuItem15 = new JMenuItem();
  JMenuItem jMenuItem16 = new JMenuItem();
  JMenuItem jMenuItem17 = new JMenuItem();
  JMenuItem jMenuItem18 = new JMenuItem();
  JMenuItem jMenuItem19 = new JMenuItem();
  JMenuItem jMenuItem20 = new JMenuItem();
  JMenuItem jMenuItem10 = new JMenuItem();
  JMenuItem jMenuItem11 = new JMenuItem();

  static Logger _logger = Logger.getLogger(ChatPopupMenu.class.getName());
  JMenuItem jMenuItem1 = new JMenuItem();
  JMenuItem jMenuItem2 = new JMenuItem();

  public ChatPopupMenu(ChatAntPanel callerChat, User user) {
    super();
    this.callerChat = callerChat;
    this.user = user;
    try {
      jbInit();
    }
    catch(Exception e) {
      _logger.error("", e);
    }
  }

  private void jbInit() throws Exception {
    jMenu1.setText(ji.JI.i("Control"));
    jMenuItem14.setText(ji.JI.i("Op"));
    jMenuItem14.addMouseListener(new ChatPopupMenu_jMenuItem14_mouseAdapter(this));
    jMenuItem15.setText(ji.JI.i("Deop"));
    jMenuItem15.addMouseListener(new ChatPopupMenu_jMenuItem15_mouseAdapter(this));
    jMenuItem16.setText(ji.JI.i("Voice"));
    jMenuItem16.addMouseListener(new ChatPopupMenu_jMenuItem16_mouseAdapter(this));
    jMenuItem17.setText(ji.JI.i("Devoice"));
    jMenuItem17.addMouseListener(new ChatPopupMenu_jMenuItem17_mouseAdapter(this));
    jMenuItem18.setText(ji.JI.i("Kick"));
    jMenuItem18.addMouseListener(new ChatPopupMenu_jMenuItem18_mouseAdapter(this));
    jMenuItem19.setText(ji.JI.i("Ban"));
    jMenuItem19.addMouseListener(new ChatPopupMenu_jMenuItem19_mouseAdapter(this));
    jMenuItem20.setText(ji.JI.i("Kick & Ban"));
    jMenuItem10.setText(ji.JI.i("Whois"));
    jMenuItem10.addMouseListener(new ChatPopupMenu_jMenuItem10_mouseAdapter(this));
    jMenuItem11.setText(ji.JI.i("PvT"));
    jMenuItem11.addMouseListener(new ChatPopupMenu_jMenuItem11_mouseAdapter(this));

    jMenuItem1.setText(ji.JI.i("Request connection"));
    jMenuItem1.addMouseListener(new ChatPopupMenu_jMenuItem1_mouseAdapter(this));
    jMenuItem2.setText(ji.JI.i("Probe firewall"));
    jMenuItem2.addMouseListener(new ChatPopupMenu_jMenuItem2_mouseAdapter(this));
    this.add(jMenuItem10);
    this.add(jMenuItem11);
    this.addSeparator();
    this.add(jMenu1);
    this.addSeparator();
    this.add(jMenuItem1);
    this.add(jMenuItem2);
    jMenu1.add(jMenuItem14);
    jMenu1.add(jMenuItem15);
    jMenu1.add(jMenuItem16);
    jMenu1.add(jMenuItem17);
    jMenu1.add(jMenuItem18);
    jMenu1.add(jMenuItem19);
    jMenu1.add(jMenuItem20);
  }

  void jMenuItem11_mousePressed(MouseEvent e) {
    if (!user.getNick().equals(ConnectionAntPanel.nick)) {
      this.callerChat.setMessage(user.getNick(), this.callerChat.bot.getNick(),
                      ji.JI.i("Query session initiated with: ") + user.getNick());
    }
  }

  void jMenuItem10_mousePressed(MouseEvent e) {
    this.callerChat.bot.sendRawLine("WHOIS " + user.getNick());
  }

  void jMenuItem14_mousePressed(MouseEvent e) {
    this.callerChat.bot.op(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem16_mousePressed(MouseEvent e) {
    this.callerChat.bot.voice(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem15_mousePressed(MouseEvent e) {
    this.callerChat.bot.deOp(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem17_mousePressed(MouseEvent e) {
    this.callerChat.bot.deVoice(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem18_mousePressed(MouseEvent e) {
    this.callerChat.bot.kick(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem19_mousePressed(MouseEvent e) {
    this.callerChat.bot.scheduleBan(user.getNick(), this.callerChat.getCurrentSelectedDiscussion());
  }

  void jMenuItem20_mousePressed(MouseEvent e) {
    this.callerChat.bot.scheduleBan(user.getNick(), this.callerChat.getCurrentSelectedDiscussion());
    this.callerChat.bot.kick(this.callerChat.getCurrentSelectedDiscussion(), user.getNick());
  }

  void jMenuItem1_mousePressed(MouseEvent e) {
    this.callerChat.bot.sendCTCPCommand(user.getNick(),
                                   "ANtsCommandCode:0001 " +
                                   FrameAnt.getInstance(null).ga.cap.getLocalStringAddress() +
                                   ":" +
                                   this.callerChat.bot.getCaller().warriorAnt.getServerPort());
  }

  void jMenuItem2_mousePressed(MouseEvent e) {
    this.callerChat.bot.sendCTCPCommand(user.getNick(),
                                           "ANtsCommandCode:0004 " +
                                           FrameAnt.getInstance(null).ga.cap.
                                           getLocalStringAddress() +
                                           ":" +
                                           this.callerChat.bot.getCaller().warriorAnt.
                                           getServerPort());
                _logger.info("Sent firewall probe message to: " +
                             user.getNick());
  }
}

class ChatPopupMenu_jMenuItem10_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem10_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem10_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem11_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem11_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem11_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem14_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem14_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem14_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem16_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem16_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem16_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem15_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem15_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem15_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem17_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem17_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem17_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem18_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem18_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem18_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem19_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem19_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem19_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem20_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem20_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem20_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem1_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem1_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem1_mousePressed(e);
  }
}

class ChatPopupMenu_jMenuItem2_mouseAdapter extends java.awt.event.MouseAdapter {
  ChatPopupMenu adaptee;

  ChatPopupMenu_jMenuItem2_mouseAdapter(ChatPopupMenu adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jMenuItem2_mousePressed(e);
  }
}




